<?php
	/**
	 * 获取场馆列表
	 */
    class VenueList extends APIBase {
		
		public $tag = "VenueList";
		public $isLogin = false;
		
		public function before() {
			$this->initCacheRedis();
			return true;
		}
       //isset()
		public function logic() {
			
			if(!isset($this->param['gameid']) || $this->param['gameid']=='' ){
			  	$gameid = 0;
				
			}else{
			    $gameid = $this->param['gameid'];
			}
			
			$venueids = $this->cache_redis->lRange("lv:ids", 0, -1);
			$venues = array();
			
			//var_dump($this->cache_redis->hGetAll('honline'));
			//exit;
			//读取房间人数
			$honline = $this->cache_redis->hGetAll('honline');
			
			foreach ($venueids as $vid) {
				
				  $venue = $this->cache_redis->hMGet("hv:{$vid}", array("GameID","name", "base_money", "min_money", "max_money", "ip", "port","versusRoomCfg"));
				 
				 if((int)$venue['GameID'] == (int)$gameid){
				  
				  $venue['GameID'] = (int)$venue['GameID'];
				  $venue['RoomID'] = (int) $vid;
				  $venue['base_money'] = (int) $venue['base_money'];
				  $venue['min_money'] = (int) $venue['min_money'];
				  $venue['max_money'] = (int) $venue['max_money'];
				  $min = (int) $venue['min_money'];
				  $max = (int) $venue['max_money'];
				  $venue['money'] = array();
				  $venue['money'][0] = $min;
				  $venue['money'][1] = $max;
				  $venue['port'] = (int) $venue['port'];	
				  $venue['versusRoomCfg'] = $venue['versusRoomCfg']?$venue['versusRoomCfg']:'';
				  
				  if(isset($honline['value'.$vid.''])){	
					$venue['onplay'] = (int)$honline['value'.$vid.''];	
				  }else{
					$venue['onplay'] = 0;	
				  }
				  
				  $venues[] = $venue;
				}else{
				   	
				}
				
			}
			$this->returnData(array('venues' => $venues));
		}
		
    	public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
